<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="__ADMIN__/css/font.css">
    <link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__ADMIN__/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
    <script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
    <style>
        .layui-btn+.layui-btn{
            margin-left: 0;
        }
        .layui-table td, .layui-table th
        {
            min-width: 50px !important;
        }
.layui-btn-xs {
    height: 22px !important;
    line-height: 22px !important;
    padding: 0 5px !important;
    font-size: 12px;
}
    </style>
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>{$nav}</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-3" style="line-height:30px"></i></a>
    </div>
    <div class="x-body x-admin">
        
        <div class="layui-table-body layui-table-main" style="width: 100%;min-height:0;">
            <table class="layui-table layui-form" lay-filter="complaints" id="complaints"> </table>
        </div>
    </div>
    <script type="text/html" id="status-td">

    </script>
    <script type="text/html" id="do-td">
    
    <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="view">详情</a>
    {{#  if(d.complaint_state != '已处理完成'){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="response">回复用户</a>
    {{#  } }}
    {{#  if(d.complaint_state != '已处理完成' && d.incoming_user_response != '是'){ }}
    <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="complete">处理完成</a>
    {{#  } }}
    </script>
    <script type="text/html" id="toolbarDemo">
      
    </script>

    <script>
      layui.use(['form','layer','jquery','table','util'], function(){
        form = layui.form,
        layer = layui.layer
        ,$ = layui.jquery
        ,table = layui.table
        ,util = layui.util;
        
          table.render({
            elem: '#complaints'
            ,url:'{:url('admin/WechatPayComplaint/index')}?mch_id={:input('mch_id')}'
            ,toolbar: '#toolbarDemo' 
            ,defaultToolbar: ['filter', 'exports', 'print']
            ,limit: 50
            ,height: $(window).height()-150
            ,title: '商户投诉表'
            ,cols: [[
              {field:'complaint_id', width:215,title:"投诉单号"},
              {field:'complaint_detail', title:"投诉详情"},
              {field:'live_id', width:108,title:"活动id"},
              {field:'complaint_state', width:108,title:"投诉单状态"},
              {field:'complaint_time', width:150,title:"投诉时间"},
              {field:'incoming_user_response', width:100,title:"是否待回复"},
              {field:'problem_description', width:150,title:"问题描述"},
              {field:'problem_type', width:100,title:"问题类型"},
              {field:'user_complaint_times', width:80,title:"投诉次数"},
              {fixed: 'right', width:200,title:"操作",  toolbar: '#do-td'},
            ]]
            ,page: true
          });
          
          table.on('tool(complaints)', function(obj){
            var data = obj.data;
            if(obj.event == 'view'){
                x_admin_show('查看详情','{:url('WechatPayComplaint/view')}/?id='+data.id+'&complaint_id='+data.complaint_id+'&mch_id='+data.mch_id,'','650','750')
            }else if(obj.event == 'response'){
                x_admin_show('查看详情','{:url('WechatPayComplaint/response')}/?id='+data.id+'&complaint_id='+data.complaint_id+'&mch_id='+data.mch_id,'','650','550')
            }else if(obj.event == 'complete'){
                layer.confirm('是否要提交处理完成？', {
                  btn: ['是','否'] 
                }, function(){
                    $.get('{:url('WechatPayComplaint/complete')}/?complaint_id='+data.complaint_id+'&mch_id='+data.mch_id,function(res){
                        if (res.message)
                        {
                          layer.alert(res.message, {icon: res.icon},function(){
                            history.go(0);
                          });    
                        }else{
                          layer.alert('操作成功', {icon: 1},function(){
                            history.go(0);
                          });    
                        }
                    })
                }, function(){
                
                });
            } 
          });

      });

    </script>
  </body>

</html>